{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from utils import *\n",
    "from constant import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:5: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "~opentop2-jump1-jump2-~foot1-foot2-~small_capq-minute-~opentop1-3\n",
      "~opentop2-speedup1-jump1-jump2-~foot1-foot2-~small_capq-~opentop1-3\n"
     ]
    }
   ],
   "source": [
    "dfs = []\n",
    "for filters in filterss:\n",
    "    for filter_key in filters:\n",
    "        to_filter = getFilter(filter_key,True) & ~yz2\n",
    "        sub_df = data_df[to_filter]\n",
    "        if len(sub_df) > 0 and \"002011.XSHE_2017-05-26\" in list(sub_df.index):\n",
    "            print filter_key\n",
    "        dfs.append(sub_df)\n",
    "df = pd.concat(dfs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:1: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)\n",
      "  if __name__ == '__main__':\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>change</th>\n",
       "      <th>date</th>\n",
       "      <th>stock</th>\n",
       "      <th>close0</th>\n",
       "      <th>high0</th>\n",
       "      <th>high_limit0</th>\n",
       "      <th>low0</th>\n",
       "      <th>open0</th>\n",
       "      <th>volume0</th>\n",
       "      <th>day0</th>\n",
       "      <th>...</th>\n",
       "      <th>volume3</th>\n",
       "      <th>day3</th>\n",
       "      <th>recent</th>\n",
       "      <th>minute_low</th>\n",
       "      <th>minute_volume</th>\n",
       "      <th>minute</th>\n",
       "      <th>st</th>\n",
       "      <th>circap</th>\n",
       "      <th>isnew</th>\n",
       "      <th>capq</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>002865.XSHE_2017-05-09</th>\n",
       "      <td>1.041667</td>\n",
       "      <td>2017-05-09 00:00:00</td>\n",
       "      <td>002865.XSHE</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>58966.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>...</td>\n",
       "      <td>13329509.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>27.00</td>\n",
       "      <td>3686300.0</td>\n",
       "      <td>09:34:00</td>\n",
       "      <td>False</td>\n",
       "      <td>91.5</td>\n",
       "      <td>True</td>\n",
       "      <td>0.027652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600874.XSHG_2017-05-15</th>\n",
       "      <td>0.970481</td>\n",
       "      <td>2017-05-15 00:00:00</td>\n",
       "      <td>600874.XSHG</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.44</td>\n",
       "      <td>18.06</td>\n",
       "      <td>18.21</td>\n",
       "      <td>160622297.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>...</td>\n",
       "      <td>138712096.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>23.11</td>\n",
       "      <td>43300500.0</td>\n",
       "      <td>09:55:00</td>\n",
       "      <td>False</td>\n",
       "      <td>3017.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.911756</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600874.XSHG_2017-05-15</th>\n",
       "      <td>0.970481</td>\n",
       "      <td>2017-05-15 00:00:00</td>\n",
       "      <td>600874.XSHG</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.44</td>\n",
       "      <td>18.06</td>\n",
       "      <td>18.21</td>\n",
       "      <td>160622297.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>...</td>\n",
       "      <td>138712096.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>23.11</td>\n",
       "      <td>43300500.0</td>\n",
       "      <td>09:55:00</td>\n",
       "      <td>False</td>\n",
       "      <td>3017.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.911756</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000852.XSHE_2017-05-19</th>\n",
       "      <td>0.984163</td>\n",
       "      <td>2017-05-19 00:00:00</td>\n",
       "      <td>000852.XSHE</td>\n",
       "      <td>14.61</td>\n",
       "      <td>14.61</td>\n",
       "      <td>14.61</td>\n",
       "      <td>13.19</td>\n",
       "      <td>13.19</td>\n",
       "      <td>39140121.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>...</td>\n",
       "      <td>121074477.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>17.00</td>\n",
       "      <td>15181500.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2561.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.773950</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000852.XSHE_2017-05-19</th>\n",
       "      <td>0.984163</td>\n",
       "      <td>2017-05-19 00:00:00</td>\n",
       "      <td>000852.XSHE</td>\n",
       "      <td>14.61</td>\n",
       "      <td>14.61</td>\n",
       "      <td>14.61</td>\n",
       "      <td>13.19</td>\n",
       "      <td>13.19</td>\n",
       "      <td>39140121.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>...</td>\n",
       "      <td>121074477.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>17.00</td>\n",
       "      <td>15181500.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2561.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.773950</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603758.XSHG_2017-05-24</th>\n",
       "      <td>1.045908</td>\n",
       "      <td>2017-05-24 00:00:00</td>\n",
       "      <td>603758.XSHG</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>100335.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>...</td>\n",
       "      <td>32581250.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>23.60</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>362.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.109399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603758.XSHG_2017-05-24</th>\n",
       "      <td>1.045908</td>\n",
       "      <td>2017-05-24 00:00:00</td>\n",
       "      <td>603758.XSHG</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>100335.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>...</td>\n",
       "      <td>32581250.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>23.60</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>362.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.109399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002011.XSHE_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>002011.XSHE</td>\n",
       "      <td>10.87</td>\n",
       "      <td>10.87</td>\n",
       "      <td>10.87</td>\n",
       "      <td>9.50</td>\n",
       "      <td>9.90</td>\n",
       "      <td>53096183.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12.71</td>\n",
       "      <td>23075000.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2622.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.792384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002011.XSHE_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>002011.XSHE</td>\n",
       "      <td>10.87</td>\n",
       "      <td>10.87</td>\n",
       "      <td>10.87</td>\n",
       "      <td>9.50</td>\n",
       "      <td>9.90</td>\n",
       "      <td>53096183.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12.71</td>\n",
       "      <td>23075000.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2622.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.792384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603896.XSHG_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>603896.XSHG</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>31.09</td>\n",
       "      <td>31.10</td>\n",
       "      <td>17344531.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>41.58</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>353.5</td>\n",
       "      <td>True</td>\n",
       "      <td>0.106830</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 39 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          change                 date        stock  close0  \\\n",
       "002865.XSHE_2017-05-09  1.041667  2017-05-09 00:00:00  002865.XSHE   25.39   \n",
       "600874.XSHG_2017-05-15  0.970481  2017-05-15 00:00:00  600874.XSHG   20.44   \n",
       "600874.XSHG_2017-05-15  0.970481  2017-05-15 00:00:00  600874.XSHG   20.44   \n",
       "000852.XSHE_2017-05-19  0.984163  2017-05-19 00:00:00  000852.XSHE   14.61   \n",
       "000852.XSHE_2017-05-19  0.984163  2017-05-19 00:00:00  000852.XSHE   14.61   \n",
       "603758.XSHG_2017-05-24  1.045908  2017-05-24 00:00:00  603758.XSHG   20.70   \n",
       "603758.XSHG_2017-05-24  1.045908  2017-05-24 00:00:00  603758.XSHG   20.70   \n",
       "002011.XSHE_2017-05-26       NaN  2017-05-26 00:00:00  002011.XSHE   10.87   \n",
       "002011.XSHE_2017-05-26       NaN  2017-05-26 00:00:00  002011.XSHE   10.87   \n",
       "603896.XSHG_2017-05-26       NaN  2017-05-26 00:00:00  603896.XSHG   35.26   \n",
       "\n",
       "                        high0  high_limit0   low0  open0      volume0  day0  \\\n",
       "002865.XSHE_2017-05-09  25.39        25.39  25.39  25.39      58966.0   3.0   \n",
       "600874.XSHG_2017-05-15  20.44        20.44  18.06  18.21  160622297.0   7.0   \n",
       "600874.XSHG_2017-05-15  20.44        20.44  18.06  18.21  160622297.0   7.0   \n",
       "000852.XSHE_2017-05-19  14.61        14.61  13.19  13.19   39140121.0  11.0   \n",
       "000852.XSHE_2017-05-19  14.61        14.61  13.19  13.19   39140121.0  11.0   \n",
       "603758.XSHG_2017-05-24  20.70        20.70  20.70  20.70     100335.0   3.0   \n",
       "603758.XSHG_2017-05-24  20.70        20.70  20.70  20.70     100335.0   3.0   \n",
       "002011.XSHE_2017-05-26  10.87        10.87   9.50   9.90   53096183.0  16.0   \n",
       "002011.XSHE_2017-05-26  10.87        10.87   9.50   9.90   53096183.0  16.0   \n",
       "603896.XSHG_2017-05-26  35.26        35.26  31.09  31.10   17344531.0  10.0   \n",
       "\n",
       "                          ...         volume3  day3  recent  minute_low  \\\n",
       "002865.XSHE_2017-05-09    ...      13329509.0   6.0     6.0       27.00   \n",
       "600874.XSHG_2017-05-15    ...     138712096.0  10.0     3.0       23.11   \n",
       "600874.XSHG_2017-05-15    ...     138712096.0  10.0     3.0       23.11   \n",
       "000852.XSHE_2017-05-19    ...     121074477.0  14.0     3.0       17.00   \n",
       "000852.XSHE_2017-05-19    ...     121074477.0  14.0     3.0       17.00   \n",
       "603758.XSHG_2017-05-24    ...      32581250.0   6.0     6.0       23.60   \n",
       "603758.XSHG_2017-05-24    ...      32581250.0   6.0     6.0       23.60   \n",
       "002011.XSHE_2017-05-26    ...             NaN   NaN     3.0       12.71   \n",
       "002011.XSHE_2017-05-26    ...             NaN   NaN     3.0       12.71   \n",
       "603896.XSHG_2017-05-26    ...             NaN   NaN     4.0       41.58   \n",
       "\n",
       "                        minute_volume    minute     st  circap  isnew  \\\n",
       "002865.XSHE_2017-05-09      3686300.0  09:34:00  False    91.5   True   \n",
       "600874.XSHG_2017-05-15     43300500.0  09:55:00  False  3017.0  False   \n",
       "600874.XSHG_2017-05-15     43300500.0  09:55:00  False  3017.0  False   \n",
       "000852.XSHE_2017-05-19     15181500.0  09:32:00  False  2561.0  False   \n",
       "000852.XSHE_2017-05-19     15181500.0  09:32:00  False  2561.0  False   \n",
       "603758.XSHG_2017-05-24            0.0  09:30:00  False   362.0   True   \n",
       "603758.XSHG_2017-05-24            0.0  09:30:00  False   362.0   True   \n",
       "002011.XSHE_2017-05-26     23075000.0  09:32:00  False  2622.0  False   \n",
       "002011.XSHE_2017-05-26     23075000.0  09:32:00  False  2622.0  False   \n",
       "603896.XSHG_2017-05-26            0.0  09:30:00  False   353.5   True   \n",
       "\n",
       "                            capq  \n",
       "002865.XSHE_2017-05-09  0.027652  \n",
       "600874.XSHG_2017-05-15  0.911756  \n",
       "600874.XSHG_2017-05-15  0.911756  \n",
       "000852.XSHE_2017-05-19  0.773950  \n",
       "000852.XSHE_2017-05-19  0.773950  \n",
       "603758.XSHG_2017-05-24  0.109399  \n",
       "603758.XSHG_2017-05-24  0.109399  \n",
       "002011.XSHE_2017-05-26  0.792384  \n",
       "002011.XSHE_2017-05-26  0.792384  \n",
       "603896.XSHG_2017-05-26  0.106830  \n",
       "\n",
       "[10 rows x 39 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort([\"date\"]).tail(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.01643438792 0.6\n"
     ]
    }
   ],
   "source": [
    "df = df.sort_values(\"minute\")\n",
    "df = df.groupby(\"date\").first()\n",
    "win_df = df[df[\"change\"] > 1.0]\n",
    "win_ratio = float(len(win_df))/len(df)\n",
    "print df.change.mean(),win_ratio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>change</th>\n",
       "      <th>stock</th>\n",
       "      <th>close0</th>\n",
       "      <th>high0</th>\n",
       "      <th>high_limit0</th>\n",
       "      <th>low0</th>\n",
       "      <th>open0</th>\n",
       "      <th>volume0</th>\n",
       "      <th>day0</th>\n",
       "      <th>close1</th>\n",
       "      <th>...</th>\n",
       "      <th>volume3</th>\n",
       "      <th>day3</th>\n",
       "      <th>recent</th>\n",
       "      <th>minute_low</th>\n",
       "      <th>minute_volume</th>\n",
       "      <th>minute</th>\n",
       "      <th>st</th>\n",
       "      <th>circap</th>\n",
       "      <th>isnew</th>\n",
       "      <th>capq</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-05-05 00:00:00</th>\n",
       "      <td>1.039953</td>\n",
       "      <td>600629.XSHG</td>\n",
       "      <td>21.10</td>\n",
       "      <td>21.30</td>\n",
       "      <td>23.40</td>\n",
       "      <td>20.72</td>\n",
       "      <td>21.01</td>\n",
       "      <td>8244148.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>23.21</td>\n",
       "      <td>...</td>\n",
       "      <td>31979454.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>23.91</td>\n",
       "      <td>4533700.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2355.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.711846</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-09 00:00:00</th>\n",
       "      <td>1.041667</td>\n",
       "      <td>002865.XSHE</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>25.39</td>\n",
       "      <td>58966.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>27.93</td>\n",
       "      <td>...</td>\n",
       "      <td>13329509.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>27.00</td>\n",
       "      <td>3686300.0</td>\n",
       "      <td>09:34:00</td>\n",
       "      <td>False</td>\n",
       "      <td>91.5</td>\n",
       "      <td>True</td>\n",
       "      <td>0.027652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-15 00:00:00</th>\n",
       "      <td>0.970481</td>\n",
       "      <td>600874.XSHG</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.44</td>\n",
       "      <td>18.06</td>\n",
       "      <td>18.21</td>\n",
       "      <td>160622297.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>22.48</td>\n",
       "      <td>...</td>\n",
       "      <td>138712096.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>23.11</td>\n",
       "      <td>43300500.0</td>\n",
       "      <td>09:55:00</td>\n",
       "      <td>False</td>\n",
       "      <td>3017.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.911756</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-19 00:00:00</th>\n",
       "      <td>0.984163</td>\n",
       "      <td>000852.XSHE</td>\n",
       "      <td>14.61</td>\n",
       "      <td>14.61</td>\n",
       "      <td>14.61</td>\n",
       "      <td>13.19</td>\n",
       "      <td>13.19</td>\n",
       "      <td>39140121.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>16.07</td>\n",
       "      <td>...</td>\n",
       "      <td>121074477.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>17.00</td>\n",
       "      <td>15181500.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2561.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.773950</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-24 00:00:00</th>\n",
       "      <td>1.045908</td>\n",
       "      <td>603758.XSHG</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>20.70</td>\n",
       "      <td>100335.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>22.77</td>\n",
       "      <td>...</td>\n",
       "      <td>32581250.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>23.60</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>362.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.109399</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-26 00:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>603896.XSHG</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>31.09</td>\n",
       "      <td>31.10</td>\n",
       "      <td>17344531.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>38.79</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>41.58</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>353.5</td>\n",
       "      <td>True</td>\n",
       "      <td>0.106830</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6 rows × 38 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       change        stock  close0  high0  high_limit0   low0  \\\n",
       "date                                                                            \n",
       "2017-05-05 00:00:00  1.039953  600629.XSHG   21.10  21.30        23.40  20.72   \n",
       "2017-05-09 00:00:00  1.041667  002865.XSHE   25.39  25.39        25.39  25.39   \n",
       "2017-05-15 00:00:00  0.970481  600874.XSHG   20.44  20.44        20.44  18.06   \n",
       "2017-05-19 00:00:00  0.984163  000852.XSHE   14.61  14.61        14.61  13.19   \n",
       "2017-05-24 00:00:00  1.045908  603758.XSHG   20.70  20.70        20.70  20.70   \n",
       "2017-05-26 00:00:00       NaN  603896.XSHG   35.26  35.26        35.26  31.09   \n",
       "\n",
       "                     open0      volume0  day0  close1    ...         volume3  \\\n",
       "date                                                     ...                   \n",
       "2017-05-05 00:00:00  21.01    8244148.0   1.0   23.21    ...      31979454.0   \n",
       "2017-05-09 00:00:00  25.39      58966.0   3.0   27.93    ...      13329509.0   \n",
       "2017-05-15 00:00:00  18.21  160622297.0   7.0   22.48    ...     138712096.0   \n",
       "2017-05-19 00:00:00  13.19   39140121.0  11.0   16.07    ...     121074477.0   \n",
       "2017-05-24 00:00:00  20.70     100335.0   3.0   22.77    ...      32581250.0   \n",
       "2017-05-26 00:00:00  31.10   17344531.0  10.0   38.79    ...             NaN   \n",
       "\n",
       "                     day3  recent  minute_low  minute_volume    minute     st  \\\n",
       "date                                                                            \n",
       "2017-05-05 00:00:00   4.0     2.0       23.91      4533700.0  09:32:00  False   \n",
       "2017-05-09 00:00:00   6.0     6.0       27.00      3686300.0  09:34:00  False   \n",
       "2017-05-15 00:00:00  10.0     3.0       23.11     43300500.0  09:55:00  False   \n",
       "2017-05-19 00:00:00  14.0     3.0       17.00     15181500.0  09:32:00  False   \n",
       "2017-05-24 00:00:00   6.0     6.0       23.60            0.0  09:30:00  False   \n",
       "2017-05-26 00:00:00   NaN     4.0       41.58            0.0  09:30:00  False   \n",
       "\n",
       "                     circap  isnew      capq  \n",
       "date                                          \n",
       "2017-05-05 00:00:00  2355.5  False  0.711846  \n",
       "2017-05-09 00:00:00    91.5   True  0.027652  \n",
       "2017-05-15 00:00:00  3017.0  False  0.911756  \n",
       "2017-05-19 00:00:00  2561.0  False  0.773950  \n",
       "2017-05-24 00:00:00   362.0   True  0.109399  \n",
       "2017-05-26 00:00:00   353.5   True  0.106830  \n",
       "\n",
       "[6 rows x 38 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change                   NaN\n",
      "stock            603896.XSHG\n",
      "close0                 35.26\n",
      "high0                  35.26\n",
      "high_limit0            35.26\n",
      "low0                   31.09\n",
      "open0                   31.1\n",
      "volume0          1.73445e+07\n",
      "day0                      10\n",
      "close1                 38.79\n",
      "high1                  38.79\n",
      "high_limit1            38.79\n",
      "low1                   35.95\n",
      "open1                     37\n",
      "volume1          1.88177e+07\n",
      "day1                      11\n",
      "close2                 42.67\n",
      "high2                  42.67\n",
      "high_limit2            42.67\n",
      "low2                   41.58\n",
      "open2                  42.28\n",
      "volume2          7.38268e+06\n",
      "day2                      12\n",
      "close3                   NaN\n",
      "high3                    NaN\n",
      "high_limit3              NaN\n",
      "low3                     NaN\n",
      "open3                    NaN\n",
      "volume3                  NaN\n",
      "day3                     NaN\n",
      "recent                     4\n",
      "minute_low             41.58\n",
      "minute_volume              0\n",
      "minute              09:30:00\n",
      "st                     False\n",
      "circap                 353.5\n",
      "isnew                   True\n",
      "capq                 0.10683\n",
      "Name: 2017-05-26 00:00:00, dtype: object\n"
     ]
    }
   ],
   "source": [
    "print df.ix[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.00157699939 0.411764705882\n"
     ]
    }
   ],
   "source": [
    "data_df = data_df.sort_values(\"minute\")\n",
    "data_df = data_df.groupby(\"date\").first()\n",
    "win_df = data_df[data_df[\"change\"] > 1.0]\n",
    "win_ratio = float(len(win_df))/len(data_df)\n",
    "print data_df.change.mean(),win_ratio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>change</th>\n",
       "      <th>stock</th>\n",
       "      <th>close0</th>\n",
       "      <th>high0</th>\n",
       "      <th>high_limit0</th>\n",
       "      <th>low0</th>\n",
       "      <th>open0</th>\n",
       "      <th>volume0</th>\n",
       "      <th>day0</th>\n",
       "      <th>close1</th>\n",
       "      <th>...</th>\n",
       "      <th>volume3</th>\n",
       "      <th>day3</th>\n",
       "      <th>recent</th>\n",
       "      <th>minute_low</th>\n",
       "      <th>minute_volume</th>\n",
       "      <th>minute</th>\n",
       "      <th>st</th>\n",
       "      <th>circap</th>\n",
       "      <th>isnew</th>\n",
       "      <th>capq</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-05-04 00:00:00</th>\n",
       "      <td>1.061268</td>\n",
       "      <td>603616.XSHG</td>\n",
       "      <td>27.80</td>\n",
       "      <td>27.80</td>\n",
       "      <td>27.80</td>\n",
       "      <td>24.41</td>\n",
       "      <td>25.37</td>\n",
       "      <td>34388364.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>29.97</td>\n",
       "      <td>...</td>\n",
       "      <td>81594848.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>32.20</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1510.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.456331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-05 00:00:00</th>\n",
       "      <td>0.964533</td>\n",
       "      <td>600581.XSHG</td>\n",
       "      <td>9.55</td>\n",
       "      <td>9.55</td>\n",
       "      <td>9.55</td>\n",
       "      <td>8.88</td>\n",
       "      <td>8.93</td>\n",
       "      <td>66374422.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.51</td>\n",
       "      <td>...</td>\n",
       "      <td>142481708.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>11.00</td>\n",
       "      <td>13831100.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2330.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.704140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-08 00:00:00</th>\n",
       "      <td>0.850437</td>\n",
       "      <td>300534.XSHE</td>\n",
       "      <td>72.88</td>\n",
       "      <td>75.45</td>\n",
       "      <td>83.45</td>\n",
       "      <td>72.32</td>\n",
       "      <td>74.93</td>\n",
       "      <td>3332581.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>80.17</td>\n",
       "      <td>...</td>\n",
       "      <td>7485700.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>24.69</td>\n",
       "      <td>1985366.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>False</td>\n",
       "      <td>388.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.117407</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-09 00:00:00</th>\n",
       "      <td>1.210269</td>\n",
       "      <td>002350.XSHE</td>\n",
       "      <td>16.90</td>\n",
       "      <td>17.25</td>\n",
       "      <td>18.71</td>\n",
       "      <td>16.76</td>\n",
       "      <td>16.80</td>\n",
       "      <td>1600783.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>18.59</td>\n",
       "      <td>...</td>\n",
       "      <td>895214.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>19.39</td>\n",
       "      <td>4559200.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1425.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.430644</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-10 00:00:00</th>\n",
       "      <td>0.943703</td>\n",
       "      <td>300481.XSHE</td>\n",
       "      <td>25.40</td>\n",
       "      <td>26.94</td>\n",
       "      <td>27.10</td>\n",
       "      <td>24.61</td>\n",
       "      <td>24.64</td>\n",
       "      <td>5763205.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>27.94</td>\n",
       "      <td>...</td>\n",
       "      <td>20989832.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>29.18</td>\n",
       "      <td>2773786.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>539.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.162889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-11 00:00:00</th>\n",
       "      <td>1.047619</td>\n",
       "      <td>002865.XSHE</td>\n",
       "      <td>30.72</td>\n",
       "      <td>30.72</td>\n",
       "      <td>30.72</td>\n",
       "      <td>26.95</td>\n",
       "      <td>27.50</td>\n",
       "      <td>12791387.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>33.79</td>\n",
       "      <td>...</td>\n",
       "      <td>18733085.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>31.88</td>\n",
       "      <td>16809800.0</td>\n",
       "      <td>14:28:00</td>\n",
       "      <td>False</td>\n",
       "      <td>178.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.053793</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-12 00:00:00</th>\n",
       "      <td>1.077338</td>\n",
       "      <td>002868.XSHE</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>40950.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>38.79</td>\n",
       "      <td>...</td>\n",
       "      <td>17519293.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>41.58</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>253.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.076458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-15 00:00:00</th>\n",
       "      <td>1.066886</td>\n",
       "      <td>002282.XSHE</td>\n",
       "      <td>20.14</td>\n",
       "      <td>20.14</td>\n",
       "      <td>20.14</td>\n",
       "      <td>17.90</td>\n",
       "      <td>18.32</td>\n",
       "      <td>40442093.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>22.15</td>\n",
       "      <td>...</td>\n",
       "      <td>75888049.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>23.97</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1526.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.461318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-16 00:00:00</th>\n",
       "      <td>1.043904</td>\n",
       "      <td>603787.XSHG</td>\n",
       "      <td>22.77</td>\n",
       "      <td>22.77</td>\n",
       "      <td>22.77</td>\n",
       "      <td>22.77</td>\n",
       "      <td>22.77</td>\n",
       "      <td>295691.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>25.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20812984.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>27.25</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>284.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.085827</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-17 00:00:00</th>\n",
       "      <td>0.989011</td>\n",
       "      <td>300021.XSHE</td>\n",
       "      <td>20.31</td>\n",
       "      <td>20.85</td>\n",
       "      <td>22.42</td>\n",
       "      <td>20.00</td>\n",
       "      <td>20.10</td>\n",
       "      <td>8786160.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>22.34</td>\n",
       "      <td>...</td>\n",
       "      <td>47655589.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>9.72</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1240.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.374736</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-18 00:00:00</th>\n",
       "      <td>0.963527</td>\n",
       "      <td>603728.XSHG</td>\n",
       "      <td>26.05</td>\n",
       "      <td>26.05</td>\n",
       "      <td>26.05</td>\n",
       "      <td>26.05</td>\n",
       "      <td>26.05</td>\n",
       "      <td>284239.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>28.66</td>\n",
       "      <td>...</td>\n",
       "      <td>27056559.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>30.88</td>\n",
       "      <td>7381500.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>671.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.202780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-19 00:00:00</th>\n",
       "      <td>0.794036</td>\n",
       "      <td>603501.XSHG</td>\n",
       "      <td>23.84</td>\n",
       "      <td>23.84</td>\n",
       "      <td>23.84</td>\n",
       "      <td>23.84</td>\n",
       "      <td>23.84</td>\n",
       "      <td>164176.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>26.22</td>\n",
       "      <td>...</td>\n",
       "      <td>12357647.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>28.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>121.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.036567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-22 00:00:00</th>\n",
       "      <td>0.924207</td>\n",
       "      <td>002350.XSHE</td>\n",
       "      <td>24.75</td>\n",
       "      <td>24.75</td>\n",
       "      <td>24.75</td>\n",
       "      <td>24.75</td>\n",
       "      <td>24.75</td>\n",
       "      <td>1223379.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>27.23</td>\n",
       "      <td>...</td>\n",
       "      <td>52191586.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>28.20</td>\n",
       "      <td>9066600.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1874.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.566334</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-23 00:00:00</th>\n",
       "      <td>0.909832</td>\n",
       "      <td>300140.XSHE</td>\n",
       "      <td>19.24</td>\n",
       "      <td>19.24</td>\n",
       "      <td>19.24</td>\n",
       "      <td>18.17</td>\n",
       "      <td>18.37</td>\n",
       "      <td>24376114.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>18.95</td>\n",
       "      <td>...</td>\n",
       "      <td>59912983.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>18.15</td>\n",
       "      <td>36444400.0</td>\n",
       "      <td>13:36:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1701.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.514053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-24 00:00:00</th>\n",
       "      <td>1.210140</td>\n",
       "      <td>300649.XSHE</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>124500.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>40.88</td>\n",
       "      <td>...</td>\n",
       "      <td>3961100.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>42.88</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>46.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.013901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-25 00:00:00</th>\n",
       "      <td>0.968523</td>\n",
       "      <td>603505.XSHG</td>\n",
       "      <td>20.48</td>\n",
       "      <td>20.48</td>\n",
       "      <td>20.48</td>\n",
       "      <td>20.11</td>\n",
       "      <td>20.48</td>\n",
       "      <td>25106749.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>22.53</td>\n",
       "      <td>...</td>\n",
       "      <td>42141600.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>24.20</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>326.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.098519</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-26 00:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>002350.XSHE</td>\n",
       "      <td>27.30</td>\n",
       "      <td>27.45</td>\n",
       "      <td>30.35</td>\n",
       "      <td>24.83</td>\n",
       "      <td>24.83</td>\n",
       "      <td>44330778.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>30.03</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>32.50</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2198.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.664400</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>17 rows × 38 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       change        stock  close0  high0  high_limit0   low0  \\\n",
       "date                                                                            \n",
       "2017-05-04 00:00:00  1.061268  603616.XSHG   27.80  27.80        27.80  24.41   \n",
       "2017-05-05 00:00:00  0.964533  600581.XSHG    9.55   9.55         9.55   8.88   \n",
       "2017-05-08 00:00:00  0.850437  300534.XSHE   72.88  75.45        83.45  72.32   \n",
       "2017-05-09 00:00:00  1.210269  002350.XSHE   16.90  17.25        18.71  16.76   \n",
       "2017-05-10 00:00:00  0.943703  300481.XSHE   25.40  26.94        27.10  24.61   \n",
       "2017-05-11 00:00:00  1.047619  002865.XSHE   30.72  30.72        30.72  26.95   \n",
       "2017-05-12 00:00:00  1.077338  002868.XSHE   35.26  35.26        35.26  35.26   \n",
       "2017-05-15 00:00:00  1.066886  002282.XSHE   20.14  20.14        20.14  17.90   \n",
       "2017-05-16 00:00:00  1.043904  603787.XSHG   22.77  22.77        22.77  22.77   \n",
       "2017-05-17 00:00:00  0.989011  300021.XSHE   20.31  20.85        22.42  20.00   \n",
       "2017-05-18 00:00:00  0.963527  603728.XSHG   26.05  26.05        26.05  26.05   \n",
       "2017-05-19 00:00:00  0.794036  603501.XSHG   23.84  23.84        23.84  23.84   \n",
       "2017-05-22 00:00:00  0.924207  002350.XSHE   24.75  24.75        24.75  24.75   \n",
       "2017-05-23 00:00:00  0.909832  300140.XSHE   19.24  19.24        19.24  18.17   \n",
       "2017-05-24 00:00:00  1.210140  300649.XSHE   37.16  37.16        37.16  37.16   \n",
       "2017-05-25 00:00:00  0.968523  603505.XSHG   20.48  20.48        20.48  20.11   \n",
       "2017-05-26 00:00:00       NaN  002350.XSHE   27.30  27.45        30.35  24.83   \n",
       "\n",
       "                     open0     volume0  day0  close1    ...         volume3  \\\n",
       "date                                                    ...                   \n",
       "2017-05-04 00:00:00  25.37  34388364.0   0.0   29.97    ...      81594848.0   \n",
       "2017-05-05 00:00:00   8.93  66374422.0   0.0   10.51    ...     142481708.0   \n",
       "2017-05-08 00:00:00  74.93   3332581.0   2.0   80.17    ...       7485700.0   \n",
       "2017-05-09 00:00:00  16.80   1600783.0   3.0   18.59    ...        895214.0   \n",
       "2017-05-10 00:00:00  24.64   5763205.0   4.0   27.94    ...      20989832.0   \n",
       "2017-05-11 00:00:00  27.50  12791387.0   5.0   33.79    ...      18733085.0   \n",
       "2017-05-12 00:00:00  35.26     40950.0   5.0   38.79    ...      17519293.0   \n",
       "2017-05-15 00:00:00  18.32  40442093.0   7.0   22.15    ...      75888049.0   \n",
       "2017-05-16 00:00:00  22.77    295691.0   8.0   25.05    ...      20812984.0   \n",
       "2017-05-17 00:00:00  20.10   8786160.0   9.0   22.34    ...      47655589.0   \n",
       "2017-05-18 00:00:00  26.05    284239.0   5.0   28.66    ...      27056559.0   \n",
       "2017-05-19 00:00:00  23.84    164176.0   9.0   26.22    ...      12357647.0   \n",
       "2017-05-22 00:00:00  24.75   1223379.0   7.0   27.23    ...      52191586.0   \n",
       "2017-05-23 00:00:00  18.37  24376114.0  13.0   18.95    ...      59912983.0   \n",
       "2017-05-24 00:00:00  37.16    124500.0  11.0   40.88    ...       3961100.0   \n",
       "2017-05-25 00:00:00  20.48  25106749.0  14.0   22.53    ...      42141600.0   \n",
       "2017-05-26 00:00:00  24.83  44330778.0  11.0   30.03    ...             NaN   \n",
       "\n",
       "                     day3  recent  minute_low  minute_volume    minute     st  \\\n",
       "date                                                                            \n",
       "2017-05-04 00:00:00   3.0     1.0       32.20            0.0  09:30:00  False   \n",
       "2017-05-05 00:00:00   3.0     3.0       11.00     13831100.0  09:31:00  False   \n",
       "2017-05-08 00:00:00   5.0     2.0       24.69      1985366.0  09:31:00  False   \n",
       "2017-05-09 00:00:00   6.0     2.0       19.39      4559200.0  09:31:00  False   \n",
       "2017-05-10 00:00:00   7.0     2.0       29.18      2773786.0  09:32:00  False   \n",
       "2017-05-11 00:00:00   8.0     8.0       31.88     16809800.0  14:28:00  False   \n",
       "2017-05-12 00:00:00   8.0     8.0       41.58            0.0  09:30:00  False   \n",
       "2017-05-15 00:00:00  10.0     3.0       23.97            0.0  09:30:00  False   \n",
       "2017-05-16 00:00:00  11.0    11.0       27.25            0.0  09:30:00  False   \n",
       "2017-05-17 00:00:00  12.0     2.0        9.72            0.0  09:30:00  False   \n",
       "2017-05-18 00:00:00   8.0     8.0       30.88      7381500.0  09:32:00  False   \n",
       "2017-05-19 00:00:00  12.0    12.0       28.00            0.0  09:30:00  False   \n",
       "2017-05-22 00:00:00  10.0     6.0       28.20      9066600.0  09:32:00  False   \n",
       "2017-05-23 00:00:00  16.0     1.0       18.15     36444400.0  13:36:00  False   \n",
       "2017-05-24 00:00:00  14.0    14.0       42.88            0.0  09:30:00  False   \n",
       "2017-05-25 00:00:00  17.0    17.0       24.20            0.0  09:30:00  False   \n",
       "2017-05-26 00:00:00   NaN     2.0       32.50            0.0  09:30:00  False   \n",
       "\n",
       "                     circap  isnew      capq  \n",
       "date                                          \n",
       "2017-05-04 00:00:00  1510.0  False  0.456331  \n",
       "2017-05-05 00:00:00  2330.0  False  0.704140  \n",
       "2017-05-08 00:00:00   388.5  False  0.117407  \n",
       "2017-05-09 00:00:00  1425.0  False  0.430644  \n",
       "2017-05-10 00:00:00   539.0  False  0.162889  \n",
       "2017-05-11 00:00:00   178.0   True  0.053793  \n",
       "2017-05-12 00:00:00   253.0   True  0.076458  \n",
       "2017-05-15 00:00:00  1526.5  False  0.461318  \n",
       "2017-05-16 00:00:00   284.0   True  0.085827  \n",
       "2017-05-17 00:00:00  1240.0  False  0.374736  \n",
       "2017-05-18 00:00:00   671.0   True  0.202780  \n",
       "2017-05-19 00:00:00   121.0   True  0.036567  \n",
       "2017-05-22 00:00:00  1874.0  False  0.566334  \n",
       "2017-05-23 00:00:00  1701.0  False  0.514053  \n",
       "2017-05-24 00:00:00    46.0   True  0.013901  \n",
       "2017-05-25 00:00:00   326.0   True  0.098519  \n",
       "2017-05-26 00:00:00  2198.5  False  0.664400  \n",
       "\n",
       "[17 rows x 38 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "144"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_df = pd.read_csv(\"top3.csv\",index_col=0, parse_dates=True)\n",
    "len(data_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:1: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)\n",
      "  if __name__ == '__main__':\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>change</th>\n",
       "      <th>date</th>\n",
       "      <th>stock</th>\n",
       "      <th>close0</th>\n",
       "      <th>high0</th>\n",
       "      <th>high_limit0</th>\n",
       "      <th>low0</th>\n",
       "      <th>open0</th>\n",
       "      <th>volume0</th>\n",
       "      <th>day0</th>\n",
       "      <th>...</th>\n",
       "      <th>volume3</th>\n",
       "      <th>day3</th>\n",
       "      <th>recent</th>\n",
       "      <th>minute_low</th>\n",
       "      <th>minute_volume</th>\n",
       "      <th>minute</th>\n",
       "      <th>st</th>\n",
       "      <th>circap</th>\n",
       "      <th>isnew</th>\n",
       "      <th>capq</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>603603.XSHG_2017-05-12</th>\n",
       "      <td>1.056995</td>\n",
       "      <td>2017-05-12 00:00:00</td>\n",
       "      <td>603603.XSHG</td>\n",
       "      <td>38.28</td>\n",
       "      <td>38.93</td>\n",
       "      <td>39.72</td>\n",
       "      <td>37.10</td>\n",
       "      <td>38.00</td>\n",
       "      <td>14140203.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>...</td>\n",
       "      <td>25187437.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>45.33</td>\n",
       "      <td>2493900.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>False</td>\n",
       "      <td>439.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.132668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603098.XSHG_2017-05-25</th>\n",
       "      <td>1.061008</td>\n",
       "      <td>2017-05-25 00:00:00</td>\n",
       "      <td>603098.XSHG</td>\n",
       "      <td>21.81</td>\n",
       "      <td>23.68</td>\n",
       "      <td>26.65</td>\n",
       "      <td>21.81</td>\n",
       "      <td>23.18</td>\n",
       "      <td>10025643.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>...</td>\n",
       "      <td>34045394.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>25.22</td>\n",
       "      <td>6670400.0</td>\n",
       "      <td>09:39:00</td>\n",
       "      <td>False</td>\n",
       "      <td>414.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.125113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603616.XSHG_2017-05-04</th>\n",
       "      <td>1.061268</td>\n",
       "      <td>2017-05-04 00:00:00</td>\n",
       "      <td>603616.XSHG</td>\n",
       "      <td>27.80</td>\n",
       "      <td>27.80</td>\n",
       "      <td>27.80</td>\n",
       "      <td>24.41</td>\n",
       "      <td>25.37</td>\n",
       "      <td>34388364.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>81594848.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>32.20</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1510.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.456331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002282.XSHE_2017-05-15</th>\n",
       "      <td>1.066886</td>\n",
       "      <td>2017-05-15 00:00:00</td>\n",
       "      <td>002282.XSHE</td>\n",
       "      <td>20.14</td>\n",
       "      <td>20.14</td>\n",
       "      <td>20.14</td>\n",
       "      <td>17.90</td>\n",
       "      <td>18.32</td>\n",
       "      <td>40442093.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>...</td>\n",
       "      <td>75888049.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>23.97</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1526.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.461318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002868.XSHE_2017-05-12</th>\n",
       "      <td>1.077338</td>\n",
       "      <td>2017-05-12 00:00:00</td>\n",
       "      <td>002868.XSHE</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>40950.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>17519293.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>41.58</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>253.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.076458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>000852.XSHE_2017-05-18</th>\n",
       "      <td>1.087119</td>\n",
       "      <td>2017-05-18 00:00:00</td>\n",
       "      <td>000852.XSHE</td>\n",
       "      <td>13.28</td>\n",
       "      <td>13.40</td>\n",
       "      <td>14.18</td>\n",
       "      <td>12.46</td>\n",
       "      <td>12.58</td>\n",
       "      <td>44472076.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>...</td>\n",
       "      <td>90122477.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>14.34</td>\n",
       "      <td>61709800.0</td>\n",
       "      <td>13:15:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2460.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.743578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002282.XSHE_2017-05-12</th>\n",
       "      <td>1.088036</td>\n",
       "      <td>2017-05-12 00:00:00</td>\n",
       "      <td>002282.XSHE</td>\n",
       "      <td>18.31</td>\n",
       "      <td>18.72</td>\n",
       "      <td>20.81</td>\n",
       "      <td>17.10</td>\n",
       "      <td>18.49</td>\n",
       "      <td>35610590.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>...</td>\n",
       "      <td>22941481.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>21.52</td>\n",
       "      <td>5563451.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1378.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.416440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603896.XSHG_2017-05-25</th>\n",
       "      <td>1.089972</td>\n",
       "      <td>2017-05-25 00:00:00</td>\n",
       "      <td>603896.XSHG</td>\n",
       "      <td>32.05</td>\n",
       "      <td>32.05</td>\n",
       "      <td>32.05</td>\n",
       "      <td>27.38</td>\n",
       "      <td>28.02</td>\n",
       "      <td>19029139.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>...</td>\n",
       "      <td>7382684.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>36.00</td>\n",
       "      <td>9798200.0</td>\n",
       "      <td>09:57:00</td>\n",
       "      <td>False</td>\n",
       "      <td>317.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.095799</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002616.XSHE_2017-05-16</th>\n",
       "      <td>1.098684</td>\n",
       "      <td>2017-05-16 00:00:00</td>\n",
       "      <td>002616.XSHE</td>\n",
       "      <td>21.35</td>\n",
       "      <td>21.77</td>\n",
       "      <td>23.25</td>\n",
       "      <td>20.80</td>\n",
       "      <td>20.99</td>\n",
       "      <td>10766611.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>...</td>\n",
       "      <td>51116103.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.96</td>\n",
       "      <td>60167800.0</td>\n",
       "      <td>14:20:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1872.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.565730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300140.XSHE_2017-05-19</th>\n",
       "      <td>1.099792</td>\n",
       "      <td>2017-05-19 00:00:00</td>\n",
       "      <td>300140.XSHE</td>\n",
       "      <td>15.90</td>\n",
       "      <td>16.13</td>\n",
       "      <td>16.13</td>\n",
       "      <td>15.02</td>\n",
       "      <td>15.20</td>\n",
       "      <td>13710457.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>...</td>\n",
       "      <td>57383803.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>18.35</td>\n",
       "      <td>4417800.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1535.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.463886</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603505.XSHG_2017-05-24</th>\n",
       "      <td>1.099867</td>\n",
       "      <td>2017-05-24 00:00:00</td>\n",
       "      <td>603505.XSHG</td>\n",
       "      <td>18.62</td>\n",
       "      <td>18.62</td>\n",
       "      <td>18.62</td>\n",
       "      <td>18.62</td>\n",
       "      <td>18.62</td>\n",
       "      <td>667938.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>...</td>\n",
       "      <td>45122233.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>20.25</td>\n",
       "      <td>11521900.0</td>\n",
       "      <td>09:37:00</td>\n",
       "      <td>False</td>\n",
       "      <td>318.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.096102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300374.XSHE_2017-05-16</th>\n",
       "      <td>1.099931</td>\n",
       "      <td>2017-05-16 00:00:00</td>\n",
       "      <td>300374.XSHE</td>\n",
       "      <td>23.82</td>\n",
       "      <td>24.68</td>\n",
       "      <td>25.29</td>\n",
       "      <td>22.69</td>\n",
       "      <td>22.85</td>\n",
       "      <td>13649181.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>...</td>\n",
       "      <td>30770863.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>28.40</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1009.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.304926</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300649.XSHE_2017-05-24</th>\n",
       "      <td>1.210140</td>\n",
       "      <td>2017-05-24 00:00:00</td>\n",
       "      <td>300649.XSHE</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>37.16</td>\n",
       "      <td>124500.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>...</td>\n",
       "      <td>3961100.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>42.88</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>46.0</td>\n",
       "      <td>True</td>\n",
       "      <td>0.013901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002350.XSHE_2017-05-09</th>\n",
       "      <td>1.210269</td>\n",
       "      <td>2017-05-09 00:00:00</td>\n",
       "      <td>002350.XSHE</td>\n",
       "      <td>16.90</td>\n",
       "      <td>17.25</td>\n",
       "      <td>18.71</td>\n",
       "      <td>16.76</td>\n",
       "      <td>16.80</td>\n",
       "      <td>1600783.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>...</td>\n",
       "      <td>895214.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>19.39</td>\n",
       "      <td>4559200.0</td>\n",
       "      <td>09:31:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1425.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.430644</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603896.XSHG_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>603896.XSHG</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>35.26</td>\n",
       "      <td>31.09</td>\n",
       "      <td>31.10</td>\n",
       "      <td>17344531.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>41.58</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>353.5</td>\n",
       "      <td>True</td>\n",
       "      <td>0.106830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300140.XSHE_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>300140.XSHE</td>\n",
       "      <td>21.57</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.44</td>\n",
       "      <td>18.36</td>\n",
       "      <td>18.97</td>\n",
       "      <td>59912983.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>24.11</td>\n",
       "      <td>31073800.0</td>\n",
       "      <td>10:18:00</td>\n",
       "      <td>False</td>\n",
       "      <td>1926.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.582049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002350.XSHE_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>002350.XSHE</td>\n",
       "      <td>27.30</td>\n",
       "      <td>27.45</td>\n",
       "      <td>30.35</td>\n",
       "      <td>24.83</td>\n",
       "      <td>24.83</td>\n",
       "      <td>44330778.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>32.50</td>\n",
       "      <td>0.0</td>\n",
       "      <td>09:30:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2198.5</td>\n",
       "      <td>False</td>\n",
       "      <td>0.664400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603098.XSHG_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>603098.XSHG</td>\n",
       "      <td>23.99</td>\n",
       "      <td>23.99</td>\n",
       "      <td>23.99</td>\n",
       "      <td>21.61</td>\n",
       "      <td>22.05</td>\n",
       "      <td>7102471.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>28.08</td>\n",
       "      <td>4358700.0</td>\n",
       "      <td>09:33:00</td>\n",
       "      <td>False</td>\n",
       "      <td>463.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.139921</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>601101.XSHG_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>601101.XSHG</td>\n",
       "      <td>6.76</td>\n",
       "      <td>6.79</td>\n",
       "      <td>7.57</td>\n",
       "      <td>6.51</td>\n",
       "      <td>6.70</td>\n",
       "      <td>8407282.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.79</td>\n",
       "      <td>14602000.0</td>\n",
       "      <td>09:41:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2515.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.760048</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>002011.XSHE_2017-05-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2017-05-26 00:00:00</td>\n",
       "      <td>002011.XSHE</td>\n",
       "      <td>10.87</td>\n",
       "      <td>10.87</td>\n",
       "      <td>10.87</td>\n",
       "      <td>9.50</td>\n",
       "      <td>9.90</td>\n",
       "      <td>53096183.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>12.71</td>\n",
       "      <td>23075000.0</td>\n",
       "      <td>09:32:00</td>\n",
       "      <td>False</td>\n",
       "      <td>2622.0</td>\n",
       "      <td>False</td>\n",
       "      <td>0.792384</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>20 rows × 39 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          change                 date        stock  close0  \\\n",
       "603603.XSHG_2017-05-12  1.056995  2017-05-12 00:00:00  603603.XSHG   38.28   \n",
       "603098.XSHG_2017-05-25  1.061008  2017-05-25 00:00:00  603098.XSHG   21.81   \n",
       "603616.XSHG_2017-05-04  1.061268  2017-05-04 00:00:00  603616.XSHG   27.80   \n",
       "002282.XSHE_2017-05-15  1.066886  2017-05-15 00:00:00  002282.XSHE   20.14   \n",
       "002868.XSHE_2017-05-12  1.077338  2017-05-12 00:00:00  002868.XSHE   35.26   \n",
       "000852.XSHE_2017-05-18  1.087119  2017-05-18 00:00:00  000852.XSHE   13.28   \n",
       "002282.XSHE_2017-05-12  1.088036  2017-05-12 00:00:00  002282.XSHE   18.31   \n",
       "603896.XSHG_2017-05-25  1.089972  2017-05-25 00:00:00  603896.XSHG   32.05   \n",
       "002616.XSHE_2017-05-16  1.098684  2017-05-16 00:00:00  002616.XSHE   21.35   \n",
       "300140.XSHE_2017-05-19  1.099792  2017-05-19 00:00:00  300140.XSHE   15.90   \n",
       "603505.XSHG_2017-05-24  1.099867  2017-05-24 00:00:00  603505.XSHG   18.62   \n",
       "300374.XSHE_2017-05-16  1.099931  2017-05-16 00:00:00  300374.XSHE   23.82   \n",
       "300649.XSHE_2017-05-24  1.210140  2017-05-24 00:00:00  300649.XSHE   37.16   \n",
       "002350.XSHE_2017-05-09  1.210269  2017-05-09 00:00:00  002350.XSHE   16.90   \n",
       "603896.XSHG_2017-05-26       NaN  2017-05-26 00:00:00  603896.XSHG   35.26   \n",
       "300140.XSHE_2017-05-26       NaN  2017-05-26 00:00:00  300140.XSHE   21.57   \n",
       "002350.XSHE_2017-05-26       NaN  2017-05-26 00:00:00  002350.XSHE   27.30   \n",
       "603098.XSHG_2017-05-26       NaN  2017-05-26 00:00:00  603098.XSHG   23.99   \n",
       "601101.XSHG_2017-05-26       NaN  2017-05-26 00:00:00  601101.XSHG    6.76   \n",
       "002011.XSHE_2017-05-26       NaN  2017-05-26 00:00:00  002011.XSHE   10.87   \n",
       "\n",
       "                        high0  high_limit0   low0  open0     volume0  day0  \\\n",
       "603603.XSHG_2017-05-12  38.93        39.72  37.10  38.00  14140203.0   6.0   \n",
       "603098.XSHG_2017-05-25  23.68        26.65  21.81  23.18  10025643.0  15.0   \n",
       "603616.XSHG_2017-05-04  27.80        27.80  24.41  25.37  34388364.0   0.0   \n",
       "002282.XSHE_2017-05-15  20.14        20.14  17.90  18.32  40442093.0   7.0   \n",
       "002868.XSHE_2017-05-12  35.26        35.26  35.26  35.26     40950.0   5.0   \n",
       "000852.XSHE_2017-05-18  13.40        14.18  12.46  12.58  44472076.0  10.0   \n",
       "002282.XSHE_2017-05-12  18.72        20.81  17.10  18.49  35610590.0   6.0   \n",
       "603896.XSHG_2017-05-25  32.05        32.05  27.38  28.02  19029139.0   9.0   \n",
       "002616.XSHE_2017-05-16  21.77        23.25  20.80  20.99  10766611.0   8.0   \n",
       "300140.XSHE_2017-05-19  16.13        16.13  15.02  15.20  13710457.0  11.0   \n",
       "603505.XSHG_2017-05-24  18.62        18.62  18.62  18.62    667938.0  13.0   \n",
       "300374.XSHE_2017-05-16  24.68        25.29  22.69  22.85  13649181.0   8.0   \n",
       "300649.XSHE_2017-05-24  37.16        37.16  37.16  37.16    124500.0  11.0   \n",
       "002350.XSHE_2017-05-09  17.25        18.71  16.76  16.80   1600783.0   3.0   \n",
       "603896.XSHG_2017-05-26  35.26        35.26  31.09  31.10  17344531.0  10.0   \n",
       "300140.XSHE_2017-05-26  22.28        22.44  18.36  18.97  59912983.0  16.0   \n",
       "002350.XSHE_2017-05-26  27.45        30.35  24.83  24.83  44330778.0  11.0   \n",
       "603098.XSHG_2017-05-26  23.99        23.99  21.61  22.05   7102471.0  16.0   \n",
       "601101.XSHG_2017-05-26   6.79         7.57   6.51   6.70   8407282.0  16.0   \n",
       "002011.XSHE_2017-05-26  10.87        10.87   9.50   9.90  53096183.0  16.0   \n",
       "\n",
       "                          ...        volume3  day3  recent  minute_low  \\\n",
       "603603.XSHG_2017-05-12    ...     25187437.0   9.0     2.0       45.33   \n",
       "603098.XSHG_2017-05-25    ...     34045394.0  18.0     2.0       25.22   \n",
       "603616.XSHG_2017-05-04    ...     81594848.0   3.0     1.0       32.20   \n",
       "002282.XSHE_2017-05-15    ...     75888049.0  10.0     3.0       23.97   \n",
       "002868.XSHE_2017-05-12    ...     17519293.0   8.0     8.0       41.58   \n",
       "000852.XSHE_2017-05-18    ...     90122477.0  13.0     2.0       14.34   \n",
       "002282.XSHE_2017-05-12    ...     22941481.0   9.0     2.0       21.52   \n",
       "603896.XSHG_2017-05-25    ...      7382684.0  12.0     3.0       36.00   \n",
       "002616.XSHE_2017-05-16    ...     51116103.0  11.0     2.0       11.96   \n",
       "300140.XSHE_2017-05-19    ...     57383803.0  14.0     2.0       18.35   \n",
       "603505.XSHG_2017-05-24    ...     45122233.0  16.0    16.0       20.25   \n",
       "300374.XSHE_2017-05-16    ...     30770863.0  11.0     2.0       28.40   \n",
       "300649.XSHE_2017-05-24    ...      3961100.0  14.0    14.0       42.88   \n",
       "002350.XSHE_2017-05-09    ...       895214.0   6.0     2.0       19.39   \n",
       "603896.XSHG_2017-05-26    ...            NaN   NaN     4.0       41.58   \n",
       "300140.XSHE_2017-05-26    ...            NaN   NaN     2.0       24.11   \n",
       "002350.XSHE_2017-05-26    ...            NaN   NaN     2.0       32.50   \n",
       "603098.XSHG_2017-05-26    ...            NaN   NaN     3.0       28.08   \n",
       "601101.XSHG_2017-05-26    ...            NaN   NaN     2.0        7.79   \n",
       "002011.XSHE_2017-05-26    ...            NaN   NaN     3.0       12.71   \n",
       "\n",
       "                        minute_volume    minute     st  circap  isnew  \\\n",
       "603603.XSHG_2017-05-12      2493900.0  09:31:00  False   439.0  False   \n",
       "603098.XSHG_2017-05-25      6670400.0  09:39:00  False   414.0  False   \n",
       "603616.XSHG_2017-05-04            0.0  09:30:00  False  1510.0  False   \n",
       "002282.XSHE_2017-05-15            0.0  09:30:00  False  1526.5  False   \n",
       "002868.XSHE_2017-05-12            0.0  09:30:00  False   253.0   True   \n",
       "000852.XSHE_2017-05-18     61709800.0  13:15:00  False  2460.5  False   \n",
       "002282.XSHE_2017-05-12      5563451.0  09:31:00  False  1378.0  False   \n",
       "603896.XSHG_2017-05-25      9798200.0  09:57:00  False   317.0   True   \n",
       "002616.XSHE_2017-05-16     60167800.0  14:20:00  False  1872.0  False   \n",
       "300140.XSHE_2017-05-19      4417800.0  09:32:00  False  1535.0  False   \n",
       "603505.XSHG_2017-05-24     11521900.0  09:37:00  False   318.0   True   \n",
       "300374.XSHE_2017-05-16            0.0  09:30:00  False  1009.0  False   \n",
       "300649.XSHE_2017-05-24            0.0  09:30:00  False    46.0   True   \n",
       "002350.XSHE_2017-05-09      4559200.0  09:31:00  False  1425.0  False   \n",
       "603896.XSHG_2017-05-26            0.0  09:30:00  False   353.5   True   \n",
       "300140.XSHE_2017-05-26     31073800.0  10:18:00  False  1926.0  False   \n",
       "002350.XSHE_2017-05-26            0.0  09:30:00  False  2198.5  False   \n",
       "603098.XSHG_2017-05-26      4358700.0  09:33:00  False   463.0  False   \n",
       "601101.XSHG_2017-05-26     14602000.0  09:41:00  False  2515.0  False   \n",
       "002011.XSHE_2017-05-26     23075000.0  09:32:00  False  2622.0  False   \n",
       "\n",
       "                            capq  \n",
       "603603.XSHG_2017-05-12  0.132668  \n",
       "603098.XSHG_2017-05-25  0.125113  \n",
       "603616.XSHG_2017-05-04  0.456331  \n",
       "002282.XSHE_2017-05-15  0.461318  \n",
       "002868.XSHE_2017-05-12  0.076458  \n",
       "000852.XSHE_2017-05-18  0.743578  \n",
       "002282.XSHE_2017-05-12  0.416440  \n",
       "603896.XSHG_2017-05-25  0.095799  \n",
       "002616.XSHE_2017-05-16  0.565730  \n",
       "300140.XSHE_2017-05-19  0.463886  \n",
       "603505.XSHG_2017-05-24  0.096102  \n",
       "300374.XSHE_2017-05-16  0.304926  \n",
       "300649.XSHE_2017-05-24  0.013901  \n",
       "002350.XSHE_2017-05-09  0.430644  \n",
       "603896.XSHG_2017-05-26  0.106830  \n",
       "300140.XSHE_2017-05-26  0.582049  \n",
       "002350.XSHE_2017-05-26  0.664400  \n",
       "603098.XSHG_2017-05-26  0.139921  \n",
       "601101.XSHG_2017-05-26  0.760048  \n",
       "002011.XSHE_2017-05-26  0.792384  \n",
       "\n",
       "[20 rows x 39 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_df = data_df.sort([\"change\"])\n",
    "data_df.tail(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0117910735214655"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_df[\"change\"].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data_df = data_df[~data_df[\"minute_low\"].isnull()]\n",
    "data_df = data_df[data_df[\"st\"] == False]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9801450440017141"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_df[\"change\"].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
